package com.gdwstudy.threadUse;

import org.omg.PortableServer.THREAD_POLICY_ID;

/**
 * @author 关道伟
 * @version 1.0
 * main线程启动两个子线程
 */
public class Thread03 {
    public static void main(String[] args) {
        T1 t1 = new T1();
        Thread thread1 = new Thread(t1);
        thread1.start();
        T2 t2 = new T2();
        Thread thread2 = new Thread(t2);
        thread2.start();
    }
}

class T1 implements Runnable{
    int count = 20;
    @Override
    public void run() {
        while(count-->0){
            //每隔一秒输出
            try {
                Thread.sleep(1000);
            } catch (InterruptedException e) {
                e.printStackTrace();
            }
            System.out.println("每隔一秒我就输出一次..."+Thread.currentThread().getName());

        }

    }
}

class T2 implements Runnable{
    int count = 4;
    @Override
    public void run() {
        while(count-->0){
            try {
                Thread.sleep(5000);
            } catch (InterruptedException e) {
                e.printStackTrace();
            }
            System.out.println("每隔五秒我就输出一次..."+Thread.currentThread().getName());

        }
    }
}
